/*
 * ConsoleFactory.java
 * 
 * Copyright 2007 Kamen Petroff.
 * All Rights Reserved.
 * 
 * This software is the proprietary information of Kamen Petroff.
 * Use is subject to license terms.
 * 
 * Created on Mar 2, 2007 at 1:57:53 PM by Kamen Petroff
 */
package com.google.code.shell4eclipse.console;

import org.eclipse.ui.console.IConsoleFactory;

import com.google.code.shell4eclipse.preferences.Preferences;
import com.google.code.shell4eclipse.process.IProcess;
import com.google.code.shell4eclipse.process.ProcessFactory;

/**
 * 
 *
 * @author Kamen Petroff 
 * @since Mar 2, 2007
 */
public class ConsoleFactory implements IConsoleFactory {

	/**
	 * @see org.eclipse.ui.console.IConsoleFactory#openConsole()
	 */
	public void openConsole() {
		ProcessBuilder processBuilder = new ProcessBuilder();
		
		processBuilder.command().add(Preferences.getExecutable());
		processBuilder.command().addAll(Preferences.getArguments());
		processBuilder.directory(Preferences.getWorkingDirectory());
		
		IProcess process = ProcessFactory.startProcess(processBuilder);
		
    	Shell4EclipseConsole console = new Shell4EclipseConsole(process);
    	console.show();
	}
	
}
